package com.mc.moring.widge

import android.content.Context
import android.util.AttributeSet
import androidx.appcompat.widget.AppCompatEditText
import androidx.core.widget.addTextChangedListener

open class TransferEditText @JvmOverloads constructor(
    context: Context, attrs: AttributeSet? = null
) : AppCompatEditText(context, attrs) {

    init {
        this.addTextChangedListener { s ->
            if (s?.isNotEmpty() == true && s.toString().startsWith(" ")) {
                this.setText(s.removePrefix(" "))
                this.setSelection(this.text?.length ?: 0)
            }
        }
    }

}